package com.yixun.lbx.service.impl;

import com.yixun.lbx.entity.YxProProductCheck;
import com.yixun.lbx.mapper.farm.ProductCheckMapper;
import com.yixun.lbx.service.ProductCheckService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class ProductCheckServiceImpl implements ProductCheckService {
    private final ProductCheckMapper checkMapper;

    public ProductCheckServiceImpl(ProductCheckMapper checkMapper) {
        this.checkMapper = checkMapper;
    }

    @Override
    public Integer getCount(HashMap<String, Object> map) {
        return checkMapper.getCount(map);
    }

    @Override
    public List<YxProProductCheck> getListByPage(HashMap<String, Object> map) {
        return checkMapper.getListByPage(map);
    }

    @Override
    public int addProductCheck(HashMap<String, Object> map) {
        map.put("addTime", getDate());
        return checkMapper.insertSelective(map);
    }

    @Override
    public int updateProductCheck(HashMap<String, Object> map) {
        map.put("updateTime", getDate());
        return checkMapper.updateByPrimaryKeySelective(map);
    }

    @Override
    public int deleteProductCheck(HashMap<String, Object> map) {
        return checkMapper.deleteByPrimaryKey(map);
    }

    @Override
    public List<YxProProductCheck> getObjByArgs(YxProProductCheck proProductCheck) {
        return checkMapper.getObjByArgs(proProductCheck);
    }

    @Override
    public List<YxProProductCheck> getSearchListByPage(HashMap<String, String> map) {
        return checkMapper.getSearchListByPage(map);
    }
    
    @Override
    public YxProProductCheck getOneById(String id) {
        return checkMapper.getOneById(id);
    }
    
    @Override
    public void deleteProductCheckByCpId(HashMap<String, Object> map) {
        checkMapper.deleteProductCheckByCpId(map);
    }
    
    private String getDate() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(new Date());
    }
}
